var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GlobalUserData"),
s = t("Hint"),
l = t("Util"),
c = t("Global"),
d = t("AssetsManager"),
h = t("Plane"),
p = cc._decorator,
u = p.ccclass,
f = p.property,
m = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.node_energy = null,
        e.node_skill = null,
        e.proBar_energy = null,
        e.node_video = null,
        e._gameManage = null,
        e.curEnergy = 0,
        e.max = 0,
        e.isUpdate = !1,
        e.shield = null,
        e
    }
    return n(e, t),
    e.prototype.onLoad = function() {
        for (var t = 1; t < this.node_skill.children.length - 1; t++) this.node_skill.children[t].getComponent(cc.Button).interactable = !1
    },
    e.prototype.init = function(t) {
        this._gameManage = t,
        this.isUpdate = !0
    },
    e.prototype.refreshStatus = function() {
        this.node_skill.children[1].getComponent(cc.Button).interactable = this.curEnergy >= 5
    },
    e.prototype.showSkillBar = function() {
        this._gameManage.isGameOver || (l.Util.videoExposure(28), l.Util.hideBanner(), cc.tween(this.node).to(.5, {
            y: -280
        },
        {
            easing: "elasticOut"
        }).start())
    },
    e.prototype.hideSkillBar = function() {
        cc.tween(this.node).to(.2, {
            y: -439.208
        }).call(function() {
            l.Util.showBanner()
        }).start()
    },
    e.prototype.start = function() {
        this.node.y = -439.208
    },
    e.prototype.onClickReleaseSkills = function(t, e) {
        var o = this;
        switch (e) {
            case "0":
                this.node_video.active && (r.default.videoTab = 28, l.Util.showRewardVideo(function() {
                o.addPlane()
            },
            function() {},
            function() {}));
            break;
            case "1":
                s.default.show("敬请期待");
            break;
            case "2":
                this.addShield();
        }
    },
    e.prototype.onStatus = function() {
        this.hideSkillBar(),
        this.scheduleOnce(this.showSkillBar, 3)
    },
    e.prototype.addPlane = function() {
        var t = this;
        l.Util.getAssets(l.Util.getBundle(d.BundleName.XIE), "Prefabs/game/skill/plane").then(function(e) {
            var o = cc.instantiate(e);
            t._gameManage.container.addChild(o),
            o.getComponent(h.default).init(t._gameManage),
            t.refreshStatus(),
            t.onStatus()
        })
    },
    e.prototype.addShield = function() {
        var t = this;
        l.Util.getAssets(l.Util.getBundle(d.BundleName.XIE), "Prefabs/game/skill/shield").then(function(e) {
            t.curEnergy -= 5,
            t.shield = cc.instantiate(e),
            t.shield.scale = 0,
            cc.tween(t.shield).to(.5, {
                scale: 2
            },
            {
                easing: "elasticOut"
            }).start(),
            t.shield.color = cc.Color.BLUE,
            t._gameManage._carLeftView.node.getChildByName("carLeft").addChild(t.shield, 999),
            r.default.skillType = c.Props.Invincible,
            t.refreshStatus(),
            t.onStatus(),
            t.scheduleOnce(function() {
                cc.tween(t.shield).to(.5, {
                    scale: 0
                }).call(function() {
                    t.shield && t.shield.destroy(),
                    t.shield = null,
                    r.default.skillType = c.Props.Unknown
                }).start()
            },
            5)
        })
    },
    e.prototype.update = function(t) {
        this.isUpdate && (this.curEnergy += .35 * t, this.curEnergy > 10 && (this.curEnergy = 10), this.refreshStatus(), this.proBar_energy.progress = this.curEnergy / 10)
    },
    a([f(cc.Node)], e.prototype, "node_energy", void 0),
    a([f(cc.Node)], e.prototype, "node_skill", void 0),
    a([f(cc.ProgressBar)], e.prototype, "proBar_energy", void 0),
    a([f(cc.Node)], e.prototype, "node_video", void 0),
    a([u], e)
} (cc.Component);
o.default = m